home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / ARCHIVES.SWG / 0017_arj files.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-25  |  5KB  |  121 lines

  1.  
  2.  
  3. const
  4.       BSize    = 4096;                                      { I/O Buffer Size }
  5.       HMax     = 512;                                   { Header Maximum Size }
  6.       DLM      = #32#179;
  7.       HexDigits: array[0..15] of char = '0123456789ABCDEF';
  8. type
  9.       MEDBUF       = array[1..4096] of char;
  10. var
  11.       DISKNUM      : Word;                     { Disk # - offset to Disk Info }
  12.       WVN          : Word;                                 { Working Volume # }
  13.       DIDX         : Word;                              { Files Display Index }
  14.       VIDX         : Word;                            { Volumes Display Index }
  15.       AIDX         : Word;                           { Archives Display Index }
  16.       CIDX         : Word;                   { Compressed Files Display Index }
  17.       ADX          : Word;                            { comPressed file Index }
  18.       RES          : Word;                                   { Buffer Residue }
  19.       N,P,Q        : Longint;
  20.       ASZ,USZ,FSZ  : LongInt;              { Disk Available, Used, Free sizes }
  21.       SEQNUM       : LongInt;                               { File Sequence # }
  22.       C            : LongInt;                                 { Buffer Offset }
  23.       FSize        : LongInt;                                     { File Size }
  24.       CH, CH1      : char;
  25.       DEVICE       : char;                                      { Disk Device }
  26.       BIN,BOUT,
  27.       BWORK        : ^MEDBUF;
  28.       F            : File;
  29.       SNAME        : String;
  30.       DATE         : string[8];                  { formatted date as YY/MM/DD }
  31.       TIME         : string[5];                  {     "     time as HH:MM    }
  32.       X1,X2,X3,X4,
  33.       X5,X6,X7,X8,
  34.       X9,X10,X11,
  35.       X12          : string;
  36.       DISKNAME     : string[15];
  37.       CMD          : string;                             { DOS Command string }
  38.       INDENT       : string;                        { Report Indention string }
  39.       GARB         : string[6];                        { extraneous device id }
  40.       PRIORAN      : STR12;                              { Prior Archive Name }
  41.       DirInfo      : SearchRec;                       { File name search type }
  42.       SR           : SearchRec;
  43.       DT           : DateTime;
  44.       PATH         : PathStr;
  45.       DIR          : DirStr;
  46.       FNAME        : NameStr;
  47.       EXT          : ExtStr;
  48.       Regs         : Registers;
  49.       Temp         : String[1];
  50.       BUFF         : array[1..BSize] of Byte;
  51.       IB           : InfoBuffer;
  52.       S            : string[11];
  53.       SNAME        : string[12];
  54.  
  55. Var I,J,K : LongInt;
  56. (**************************** ARJ Files Processing ***************************)
  57. Type  AHMain = record                                           { ARJ Headers }
  58.                  HeadId  : Word;                                      { 60000 }
  59.                  BHdrSz  : Word;                          { Basic Header Size }
  60.                  FHdrSz  : Byte;                           { File Header Size }
  61.                  AVNo    : Byte;
  62.                  MAVX    : Byte;
  63.                  HostOS  : Byte;
  64.                  Flags   : Byte;
  65.                  SVer    : Byte;
  66.                  FType   : Byte;                 { must be 2 for basic header }
  67.                  Res1    : Byte;
  68.                  DOS_DT  : LongInt;
  69.                  CSize   : LongInt;                         { Compressed Size }
  70.                  OSize   : LongInt;                           { Original Size }
  71.                  SEFP    : LongInt;
  72.                  FSFPos  : Word;
  73.                  SEDLgn  : Word;
  74.                  Res2    : Word;
  75.                  NameDat : array[1..120] of char;       { start of Name, etc. }
  76.                  Res3    : array[1..10] of char;
  77.                end;
  78. Var ARJ1     : AHMain;
  79. procedure GET_ARJ_ENTRY;
  80. begin
  81.   FillChar(ARJ1,SizeOf(AHMain),#0); FillChar(BUFF,BSize,#0);
  82.   Seek (F,C-1); BlockRead(F,BUFF,BSIZE,RES);        { read header into buffer }
  83.   Move (BUFF[1],ARJ1,SizeOf(AHMain)); FSize := 0;
  84.   with ARJ1 do
  85.     begin
  86.       if BHdrSz > 0 then
  87.         begin
  88.           I := 1; SNAME := B40;
  89.           while NameDat[I] > #0 do Inc (I);       { scan for end of file name }
  90.           Move (NameDat[1],SNAME[1],I-1); SNAME[0] := Chr(I-1);
  91.           FSize := BHdrSz+CSize;
  92.           if FType = 2 then FSize := BHdrSz;
  93.           if BHdrSz = 0 then FSize := 0;
  94.         end;  { if }
  95.     end;  { with }
  96. end;  { GET_ARJ_ENTRY }
  97.  
  98. procedure DO_ARJ (FN : string);
  99. begin
  100.   Assign (F,FN); Reset (F,1); C := 1;
  101.   GET_ARJ_ENTRY;                                        { Process file Header }
  102.   while FSize > 0 do
  103.     begin
  104.       Inc(C,FSize+10); GET_ARJ_ENTRY;                         { get file info }
  105.       if FSize > 0 then
  106.         begin
  107.           with ARJ1 do
  108.             begin
  109.               FSplit (SNAME,DIR,FNAME,EXT);
  110.               if Length(EXT) <= 0 then EXT := '    ';
  111.               while Pos(#00,FNAME) > 0 do FNAME[Pos(#00,FNAME)] := ' ';
  112.               F := Copy(FNAME+B40,1,8); E := Copy(EXT+'    ',1,4);
  113.               SIZE := OSize; RTYPE := 4; D_T := DOS_DT;
  114.               ANUM := ADX; VNUM := VDX;
  115.             end;
  116.         end;  { if }
  117.     end;  { while }
  118.   Close (F);
  119. end;  { DO_ARJ }
  120.  
  121.